import tkinter as tk

# 创建窗口对象
win = tk.Tk()
win.title("第一个gui程序")
win.geometry("500x400+300+200")  # 宽500,高400，坐标x轴300，y轴200
# win.iconbitmap(图片路径) 仅支持ico文件
# win["bg"]="red" # 设置窗口颜色
# win.attributes("-alpha",0.6) 设置窗口透明度 0全透明，1全不透明
# win.attributes("-fullscreen",True) # True设置全屏
# win.attributes("-topmost",True) # True设置窗口置顶
# 获取电脑屏幕大小
scree_height = win.winfo_screenheight()
scree_width = win.winfo_screenwidth()
print(f"电脑屏幕宽{scree_width}，高{scree_height}")
# win.geometry(f"{int(scree_width*0.5)}x{int(scree_height*0.5)}") 窗体居中显示
""" 
绝对布局：place(x=值,y=值)
相对布局：pack()
网格布局：grid(row=行数,column=列数)
"""
# 标签组件
Label1 = tk.Label(win, text="我是网格布局标签", font=("宋体", 18)).grid(row=0, column=0)
Label2 = tk.Label(win, text="我是绝对布局标签", font=("宋体", 18)).place(x=0, y=32)
# Label2 = tk.Label(win, text="我是相对布局标签", font=("宋体", 18)).pack()


# 显示窗口
win.mainloop()
